<?php
namespace Common\Model;
use Common\Extend\Weixin\TPWechat;
use Think\Model;
/**
 * Created by PhpStorm.
 * User: xmlijian-mac
 * Date: 15/8/5
 * Time: 下午7:52
 */
class MemberModel extends Model
{
    public function addUser($openid){
        $wx = new TPWechat(C('WEIXIN_CONFIG'));
        $user = $wx->getUserInfo($openid);
        print_r($user);
    }

    /**
     * 获取用户信息
     * @param $openid
     * @return array|bool|mixed
     */
    public function getUser($openid){
        $user = $this->where(array('openid'=>$openid))->find();
        if(!$user) return false;
        if($user['addtime']+2592000<time()){
            $wx = new TPWechat(C('WEIXIN_CONFIG'));
            $user = $wx->getUserInfo($openid);
        }
        return $user;
    }
}